﻿@using Microsoft.Web.Mvc
@using SapaFinance.DTO
@using SapaFinance.UI.Controllers
@using Telerik.Web.Mvc.UI
@model IEnumerable<OrderDTO>
@{
    ViewBag.Title = "Список распоряжений";
}
<div>
    @(Html.Telerik().Grid(Model)
               .PrefixUrlParameters(false) //http://demos.telerik.com/aspnet-mvc/grid/serverbinding?Grid-page=1&Grid-orderBy=~&Grid-groupBy=~&Grid-filter=~
               .Name("Grid")
               .DataKeys(keys => { keys.Add(o => o.UID); })
               .TableHtmlAttributes(new { id = "MyTable" })
               .Columns(columns =>
                        {
                            columns.Template(@<text>
    <input name="checkedRecords" type="checkbox" value="@item.UID" title="checkedRecords"/></text>).Width(50)
                                .Title("<input id='mastercheckbox' type='checkbox' checked='checked' />") // add checkbox to header
                                .HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:center" });
                            columns.Bound(o => o.Number).Width(60);
                            columns.Template(r => @Html.ActionLink<HomeController>(x => x.Requests(), "посмотреть", new { id = "{0}" }).ToHtmlString()).Title("Заявки").Width(100);
                            columns.Bound(o => o.Created).Width(200);
                            columns.Bound(o => o.PaymentPeriod).Format("{0:dd/MM/yyyy}").Width(100);
                            columns.Template(@<text>@item.Payment@item.CurrencyName</text>).Title("Оплатить").Width(150);
                            columns.Bound(o => o.PayeeSharePie).Width(150);
                            columns.Bound(o => o.PayerSharePie).Width(150);
                            columns.Bound(o => o.AgentName).Width(150);
                            columns.Bound(o => o.CreatedBy).Width(200);
                            columns.Template(r => @Html.ActionLink<HomeController>(x => x.Payments(), "посмотреть", new { id = "{0}" }).ToHtmlString()).Title("Оплаты").Width(100);
                            columns.Command(commands =>
                                            {
                                                commands.Edit();
                                                commands.Delete();
                                            });
                        })
               .DataBinding(dataBinding => dataBinding.Server()
                                               .Select<OrderController>(x => x.Index())
                                               .Insert("Insert", "Order")
                                               .Update("Update", "Order")
                                               .Delete("Delete", "Order")
               )
               .Sortable(sorting => sorting.Enabled(true))
               .Selectable(x => x.Enabled(true))
               .Editable(x => x.Enabled(true).Mode(GridEditMode.PopUp).Window(p => p.ClientEvents(z => z.OnOpen("CenterPopupWindow")))))
</div>
